package com.ysxsoft.wdg.ui.activity.my;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.base.BaseActivity;
import com.ysxsoft.wdg.bean.response.PinDetailResponse;
import com.ysxsoft.wdg.bean.response.ShopInfoResponse;
import com.ysxsoft.wdg.net.CallbackCode;
import com.ysxsoft.wdg.net.UrlHost;
import com.ysxsoft.wdg.util.JsonUtils;
import com.ysxsoft.wdg.util.ToastUtils;
import com.ysxsoft.wdg.util.sp.SharePrefUtils;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;

public class MyShopActivity extends BaseActivity {
    @BindView(R.id.topView)
    View topView;
    @BindView(R.id.title_finish)
    ImageView titleFinish;
    @BindView(R.id.title_content)
    TextView titleContent;
    @BindView(R.id.title_iv_r)
    ImageView titleIvR;
    @BindView(R.id.title_tv_r)
    TextView titleTvR;@BindView(R.id.shopName)
    TextView shopName;
    @BindView(R.id.bg)
    ImageView bg;  @BindView(R.id.logo)
    ImageView logo;
    @BindView(R.id.vi)
    View vi;
    @BindView(R.id.tel)
    TextView tel;
    @BindView(R.id.address)
    TextView address;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_shop;
    }

    @Override
    protected void initData() {
        initStatusBar(topView, true);
        titleContent.setText("商家");

        getDetail();
    }

    @Override
    protected void setListener() {

    }

    @OnClick(R.id.title_finish)
    public void onViewClicked() {
        finish();
    }

    /**
     * 获取商铺订单详情
     */
    private void getDetail() {
        OkHttpUtils.post()
                .url(UrlHost.SHOP_INFO)
                .addParams("uid", SharePrefUtils.getUserId())
                .tag(this)
                .build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                if (!call.isCanceled()) {
                }
            }

            @Override
            public void onResponse(String response, int id) {
                if (response != null) {
                    ShopInfoResponse shopInfoResponse = JsonUtils.parseByGson(response, ShopInfoResponse.class);
                    if (shopInfoResponse == null) {
                        return;
                    }
                    if (CallbackCode.SUCCESS.equals(shopInfoResponse.getCode())) {
                        ToastUtils.showToast(shopInfoResponse.getMs());
                        ShopInfoResponse.DataBean d=shopInfoResponse.getData();
                        Glide.with(MyShopActivity.this).load(d.getPic()).into(logo);
                        tel.setText(d.getPhone());
                        address.setText(d.getMap_address());
                        shopName.setText(d.getName());
                    } else {
                        ToastUtils.showToast(shopInfoResponse.getMs());
                    }
                } else {
                }
            }
        });
    }
}
